global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.
  evaluation_interval: 15s # By default, scrape targets every 15 seconds.
  # scrape_timeout is set to the global default (10s).

  # The labels to add to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
    monitor: 'master'



{% if prometheus_rule_files is defined %}
# Rule files specifies a list of files from which rules are read.
rule_files:
  {% for (key, value) in prometheus_rule_files.iteritems() %}
  - {{ prometheus_rule_path }}/{{ value.dest }}
  {% endfor %}
{% endif %}



# A list of scrape configurations.
scrape_configs:

  - job_name: 'prometheus'
    scrape_interval: 10s
    scrape_timeout:  10s
    static_configs:
      - targets: ['localhost:9090']

  - job_name: "node"
    file_sd_configs:
      - files:
        - '{{ prometheus_file_sd_config_path }}/*.json'
        - '{{ prometheus_file_sd_config_path }}/*.yml'
        - '{{ prometheus_file_sd_config_path }}/*.yaml'
    #static_configs:
    #- targets:
    #  - "localhost:9100"


{% if prometheus_mysql_monitor is defined %}
  # mysqld monitor
  - job_name: 'mysqld'
    metrics_path: '/metrics'
    static_configs:
      - targets: ['{{ prometheus_mysql_monitor }}']
{% endif %}

{% if consul_sd_host is defined %}
  # CentOS 监控
  - job_name: 'centos7-consul'
    metrics_path: '/metrics'
    consul_sd_configs:
      - server: {{ consul_sd_host }}
        services:
          - node_exporter
{% endif %}

{% if prometheus_jenkins_monitor is defined %}
  # Jenkins 监控
  - job_name: 'Jenkins'
    metrics_path: '/prometheus'
    static_configs:
      - targets: ['{{ prometheus_jenkins_monitor }}']
{% endif %}

{% if consul_sd_host is defined %}
  # SpringBoot 监控
  - job_name: 'alinesno-cloud-boot'
    metrics_path: '/actuator/prometheus'
    consul_sd_configs:
      - server: {{ consul_sd_host }}
        services:
          - alinesno_cloud_exporte
{% endif %}

{% if prometheus_alertmanager_hostport is defined %}
alerting:
  alertmanagers:
    - static_configs:
      - targets: [ {{ prometheus_alertmanager_hostport }} ]
{% endif %}
